package com.qdxy.app.lhjh.activities.fragments;

import android.content.DialogInterface;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import com.lf.tempcore.tempFragment.TempFragment;
import com.lf.tempcore.tempViews.tempRecyclerView.TempRVCommonAdapter;
import com.lf.tempcore.tempViews.tempRecyclerView.TempRVHolder;
import com.qdxy.app.lhjh.R;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by KY on 2016/10/9.
 * 装箱
 */

public class FragZhuangXiang extends TempFragment {
    private RecyclerView mRecyclerView;

    @Override
    protected View initViews(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return inflater.inflate(R.layout.frag_zhuang_xiang_layout, null);
    }

    @Override
    protected void setListeners(View view, @Nullable Bundle savedInstanceState) {

    }

    @Override
    protected void bundleValues(View view, @Nullable Bundle savedInstanceState) {
        mRecyclerView = (RecyclerView) view.findViewById(R.id.frag_zhuang_xiang_RecyclerView);
        List<String> itemData = new ArrayList<>();
        itemData.add("0");
        itemData.add("1");
        itemData.add("2");
        itemData.add("3");
        itemData.add("4");

        initListData(mRecyclerView, itemData);
    }

    @Override
    protected void OnViewClicked(View v) {

    }

    private void initListData(RecyclerView rv, List<String> itemData) {
        rv.setLayoutManager(new LinearLayoutManager(getActivity()));
        TempRVCommonAdapter<String> adapter = new TempRVCommonAdapter<String>(getActivity(), R.layout.item_zhuang_xiang_layout) {
            @Override
            public void bindItemValues(TempRVHolder holder, final String s) {
                holder.setOnClickListener(R.id.item_zhuang_xiang_btn, new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        showChangeKnife();
//                        Toast.makeText(getActivity(), "content="+s, Toast.LENGTH_SHORT).show();
                    }
                });
                holder.setOnClickListener(R.id.item_zhuang_xiang_commit_btn, new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Toast.makeText(getActivity(), "content="+s, Toast.LENGTH_SHORT).show();
                    }
                });
            }
        };
        rv.setAdapter(adapter);
        adapter.updateRefresh(itemData);
    }
    /**
     * 更换刀具对话框
     */
    private void showChangeKnife(){
        String[] data =new String[]{"产品编号：wd120600909101","产品编号：wd120600909102","产品编号：wd120600909103","产品编号：wd120600909104","产品编号：wd120600909105"};
        boolean[] choose =new boolean[]{true,false,false,false,false};
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        builder.setMultiChoiceItems(data, choose, new DialogInterface.OnMultiChoiceClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which, boolean isChecked) {

            }
        }).setNegativeButton("取消",null).setPositiveButton("确定",null).show();


    }
}
